package com.iRomantic.domain.entity;

import java.sql.Timestamp;
import java.util.UUID;

import com.iRomantic.config.Constant;
import com.jfinal.plugin.activerecord.Model;

/**
 * 请帖
 * @author serenity
 *
 */
public class Invitation extends Model<Invitation> {
	
	private static final long serialVersionUID = -3474037700357117228L;
	
	public static final Invitation DAO = new Invitation();

	public boolean save(){
		if(this.getStr("id")==null){
			this.set("id", UUID.randomUUID().toString());
		}
		this.set("createTime", new Timestamp(System.currentTimeMillis()));
		return super.save();
	}
	
	public void setOSSPath(Invitation invitation){
		if(null!=invitation.getStr("url")){
			invitation.set("url", Constant.OSS_PATH+Constant.INVITATION_PICTURE +invitation.getStr("weddingId")+"/"+invitation.getStr("url"));
		}else{
			invitation.set("url", Constant.OSS_PATH+Constant.INVITATION_PICTURE +invitation.getStr("weddingId")+"/"+"default.jpg");
		}
	}
	
}
